    /**
     * 防止活动重复提交;
     */
    var submitFn = true;
 
    /**活动券类型,全场券＋单品券;*/
    var ACTIVITY_TICKET_TYPE = {"ALL_TICKET":"MONEY","SIG_TICKET":"MONEY","EXCHANGE_TICKET":"EXCHANGE","DISCOUNT_TICKET":"REDUCETO"};
    var defaultPublicParam =  {
            "activityType":"",//活动类型 see getActivityName()
            "crowdGroupId":"",
            "activityStartTime":"",//活动开始时间
            "activityEndTime":"",//活动开始时间
            "voucherStartTime":"",
            "voucherEndTime":"",
            "autoDelayFlag":"Y",//自动续期
            "activityName":"",//活动名称;
            "voucherLogo":"",//默认券logoId;
            "voucherLogoUri":"",//默认券logo图片;
            "voucherSubTitle":"",//默认券名称;
            "voucherWorthValue":"",//券面额;
            "voucherMinConsume":"",//券消费门槛;
            "voucherRelativeTime":"",//默认30天;
            "isRelativeTime":true,//是否相对时间默认相对;
            "promoSendRuleMincost":"",
            "brandName":"",
            "isOpenKbk":false,//是否开启口碑客,默认关闭;
            "commissionSettingCheck":"0",//是否分佣金
            "percentageClauseRate":"",//佣金比例;
            "percentageClauseMax":"",//限制最大金额;
            "quotaClauseQuotaAmount":"",//单品固定分佣金额;
            "voucherSlogan":"",//专项优惠文案;
            "voucherSloganUrlId":"",//专项优惠图片Id;
            "voucherSloganUri":"",//专项优惠图片URL;
            "voucherSloganNewUri":"",//专项优惠图片URL;
            "voucherSloganNewId":"",//专项优惠图片URL;
            "voucherSloganLocalFilePath":"",//专项优惠图片本地文件最新的路径;
            "voucherSloganLocalOldFilePath":"",//专项优惠图片本地文件上一次选择的图片路径;"
            "signedKbk":false,//是否签约口碑客默认没有签约;
            "voucherType":ACTIVITY_TICKET_TYPE.ALL_TICKET,
            //"configCode":"1",//活动配置code
            "goodsInfo":{},//商品信息;
            "prerequisiteData":{},//活动预加载数据;
            "kbkConfigInfo":{},//口碑客默认推荐配置;
            "otherSetting":{},//其他设置页面设置的;      
            "defaultParam":{},//首页默认参数
            "voucherData":[],//设置优惠券信息数据(阶梯有可能为多个);
            //"defaultEffectData":{},//预期效果默认参数
            //"defaultOtherSetting":{},//其他设置页默认参数
            "channelType":[],//渠道类型 店铺: SHOP_DETAIL 支付成功页: PAYMENT_RESULT 短链接: SHORT_LINK 二维码: QR_CODE
            "affiliation":"",//渠道归属;
            "channelData":{},
          "selectDateParams" : {
              "pageId" : "",//当前页面pageId;
              "beginDateInputId" : "",//开始日期input的Id;
              "endDateInputId" : "",//结束日期的input的Id;
              "selectBeginDateFunc" : "",//开始日期联动执行的选择callback事件
              "selectEndDateFunc" : "" //结束日期联动执行的选择callback事件
          }
    };
    
    /**
        创建活动的全局参数
    **/
    var createActivityPublicParam = (createActivityPublicParam!=undefined && createActivityPublicParam.activityType!="")?createActivityPublicParam:$.extend({}, defaultPublicParam);
    
    
    
    /**
     * 构建创建活动提交json数据;
     * @returns {___anonymous1870_1871}
     */
   function buildActivitySubmitData(marketingMethod){
	        var submitParam = {"clientFlag":"app","promoTools":[]};
	        var otherSetting = createActivityPublicParam.otherSetting;
	        var act = ActivityUtil.getActivityByType(createActivityPublicParam.activityType);

          if(marketingMethod==2){
             submitParam.configCode = otherSetting.configCode.split("|")[0];
          }

	        //活动规则
	        submitParam.marketingMethod = marketingMethod==null?1:marketingMethod;//营销手段 1:普通创建 2:一键营销创建
	        submitParam.activityType = createActivityPublicParam.activityType;//活动类型
	        submitParam.crowdGroupId = createActivityPublicParam.crowdGroupId;//人群Id
	        submitParam.activityName = otherSetting.activityName;//活动名称
	        submitParam.activityStartTime = createActivityPublicParam.activityStartTime;
	        submitParam.activityEndTime = createActivityPublicParam.activityEndTime;
	        submitParam.autoDelayFlag = createActivityPublicParam.autoDelayFlag;
	        submitParam.budgetValueSelect = otherSetting.budgetValueSelect;
	        submitParam.budgetValue = otherSetting.budgetValue;
	        submitParam.userWinCountSelect = otherSetting.userWinCountSelect;
	        submitParam.userWinCount = otherSetting.userWinCount;
	        submitParam.commissionSettingCheck = createActivityPublicParam.commissionSettingCheck;
	        submitParam.percentageClauseRate = createActivityPublicParam.percentageClauseRate;
	        submitParam.percentageClauseMax = createActivityPublicParam.percentageClauseMax;  
            submitParam.quotaClauseQuotaAmount = createActivityPublicParam.quotaClauseQuotaAmount;
	        //自定义人群活动-一键营销挽回流失会员，都在这里赋值，多了也无妨
            submitParam.crowdGroupId = otherSetting.crowdGroupId;

	        //单日领取上限
	        submitParam.userWinFrequencySelect  = otherSetting.userWinFrequencySelect;
	        submitParam.userWinFrequencyValue = otherSetting.userWinFrequencyValue;
            //是否选择全部门店--1：全部，2：部分
	        submitParam.suitShopsSelect = otherSetting.suitShopsSelect;
	        if(otherSetting.suitShopsSelect =="2"){//局部选择门店;
	             //门店多个Id，用逗号分隔;
	             submitParam.suitShops=otherSetting.suitShops;
	        }
	        if (act.isHaveChannel == "yes") {
	        	//优惠专属文案和图片;
		        submitParam.voucherSlogan = createActivityPublicParam.voucherSlogan;
		        submitParam.voucherSloganUrlId = createActivityPublicParam.voucherSloganUrlId;
		        submitParam.voucherSloganUri = createActivityPublicParam.voucherSloganUri;
		        //渠道类型;
		        submitParam.channelType = createActivityPublicParam.channelType;	 
		        //渠道归属;
	        }     
	        submitParam.affiliation = createActivityPublicParam.affiliation;
	        
	        if(act.val == ACTIVITY_TYPE.LATTER_SEND.val){
	        	for(var i=0;i<createActivityPublicParam.voucherData.length;i++){
	        		otherSetting.voucherWorthValue = createActivityPublicParam.voucherData[i].voucherWorthValue;
	        		otherSetting.voucherMinConsume =  createActivityPublicParam.voucherData[i].voucherMinConsume;
	        		otherSetting.voucherName = createActivityPublicParam.voucherData[i].voucherName;
	        		otherSetting.promoSendRuleMincost =  createActivityPublicParam.voucherData[i].receiveConditionMoney;
	        		submitParam.promoTools.push(setVoucher(otherSetting));
	        	}
	        }
          else if(act.val==ACTIVITY_TYPE.SEND_FOR_CONSUME.val || act.val==ACTIVITY_TYPE.CROWD_SEND_FOR_CONSUME.val){
              //消费送券是多券,特殊处理
              submitParam.promoTools = [];
              $.each(otherSetting.promoTools,function(i,e) {
                $.extend(otherSetting,e);
                var v = setVoucher(otherSetting);
                v.crowdGroupId = e.crowdGroupId;
                submitParam.promoTools.push(v);
              });

          }else{
	           submitParam.promoTools[0] = setVoucher(otherSetting);
	        } 

            return submitParam;
	   
   }

   function jumpOtherSettingPage(){
        var otherSetting = createActivityPublicParam.otherSetting;
        var voucherValidateType = createActivityPublicParam.isRelativeTime?"RELATIVE":"FIXED";
        otherSetting.voucherValidateType = voucherValidateType;
        // otherSetting.voucherWorthValue = otherSetting.voucherWorthValue;//券面额
        // otherSetting.voucherMinConsume = otherSetting.voucherMinConsume;//消费满
        // otherSetting.promoSendRuleMincost = otherSetting.promoSendRuleMincost;//订单满
        // otherSetting.voucherSubTitle = otherSetting.voucherSubTitle;//品牌名称
        // otherSetting.voucherLogo = otherSetting.voucherLogo;//品牌logo
        // otherSetting.voucherLogoUri = otherSetting.voucherLogoUri;//品牌logo
        // otherSetting.voucherRelativeTime = otherSetting.voucherRelativeTime;//时间
        //跳转其他设置页面
        CommonUtil.injectParamObject(otherSetting);
        $.router.load("create_activity_other_setting.html");
   }
   
   /**
    * 代金券类型转换;
    * @param voucherType
    * @returns {Number}
    */
   function getMoneyVoucherType(voucherType){	   
	   var moneyVoucherType = 1;//默认全场代金券;
  	    if(voucherType==ACTIVITY_TICKET_TYPE.ALL_TICKET){//全场代金券;
  	    	moneyVoucherType = 1;
  	    }else if(voucherType ==ACTIVITY_TICKET_TYPE.SIG_TICKET){//单品代金券;
  	    	moneyVoucherType = 2;
  	    }else if(voucherType ==ACTIVITY_TICKET_TYPE.DISCOUNT_TICKET){//折扣券
			moneyVoucherType = 4;
		}else{//兑换券;
  	    	moneyVoucherType = 3; 	    	 
  	    }
	   return moneyVoucherType;
   }
   
   
   function setVoucher(otherSetting){
	    //设置代金券信息;
       var voucher = {};
       voucher.voucherType = otherSetting.voucherType;
       voucher.moneyVoucherType =(createActivityPublicParam.activityType == ACTIVITY_TYPE.ITEM_MARKET.val)?"2":"1";
       voucher.voucherWorthValue = otherSetting.voucherWorthValue;
       voucher.voucherMinConsume = otherSetting.voucherMinConsume;
       voucher.voucherRelativeTime = otherSetting.voucherRelativeTime;
       voucher.promoSendRuleMincost  = (otherSetting.promoSendRuleMincost)?otherSetting.promoSendRuleMincost:0;
       if(CommonUtil.isEmpty(otherSetting.voucherName)){
           voucher.voucherName = buildVourcherName();//券名称
       }else{
           voucher.voucherName = otherSetting.voucherName;//券名称
       }
       voucher.voucherStartTime         = createActivityPublicParam.voucherStartTime;  //券有效期 开始时间
       voucher.voucherEndTime           = createActivityPublicParam.voucherEndTime;    //券有效期 截止时间
       voucher.voucherSubTitle = otherSetting.voucherSubTitle;//品牌名称
       voucher.voucherLogo = otherSetting.voucherLogo;//券logo
       voucher.voucherLogoUri = otherSetting.voucherLogoUri;
       voucher.voucherImg = otherSetting.voucherImg;//券的图片
       voucher.voucherImgUri = otherSetting.voucherImgUri;
       //券有效期类型RELATIVE FIXED
       voucher.voucherValidateType = otherSetting.voucherValidateType=="undefined"?"RELATIVE":otherSetting.voucherValidateType;
       //券生效的方式 立即还是延迟--目前支持:立即生效：“IMMEDIATELY”，延迟生效：DELAY
       voucher.voucherEffectType = otherSetting.voucherEffectType;
       //是否可转赠 可空 ：1：可转增，0：不可转增 
       voucher.voucherDonateFlag = otherSetting.voucherDonateFlag;
       //券的使用说明
       voucher.voucherUseInstructions = otherSetting.voucherUseInstructions;           
       //券的可用时间段是否受限：1：不受限，2：受限 
       voucher.voucherUseTimeSelect = otherSetting.voucherUseTimeSelect;
       //券的可用时间段
       voucher.voucherUseTime = otherSetting.voucherUseTime;
       //券的可用时间段是否受限：1：不受限，2：受限
       voucher.voucherForbiddenTimeSelect = otherSetting.voucherForbiddenTimeSelect;
       //券不可用时间
       voucher.voucherForbiddenTime = otherSetting.voucherForbiddenTime;
       //券的备注
       voucher.voucherNote = otherSetting.voucherNote;
       if(createActivityPublicParam.activityType == ACTIVITY_TYPE.ITEM_MARKET.val){
    	   voucher.itemName = createActivityPublicParam.goodsInfo.goodsName;//商品名称;
    	   if(createActivityPublicParam.goodsInfo.goodsPicUrl!="" && createActivityPublicParam.goodsInfo.goodsPicId!=""){//商品图片;
    		   voucher.itemImgs = [{"id":createActivityPublicParam.goodsInfo.goodsPicId,"url":createActivityPublicParam.goodsInfo.goodsPicUrl}];
    	   }   	   
       }
    
       return voucher;
	   
   }
   
    
   /**
    * 构建其他设置默认数据;
    */
   function buildDefaultOtherSetting(){
       var otherSetting = createActivityPublicParam.otherSetting;
       otherSetting.activityType = createActivityPublicParam.activityType;//活动类型
       otherSetting.crowdGroupId = "";//活动人群
       otherSetting.configCode = "";//
       otherSetting.activityName = buildActivityName(createActivityPublicParam.activityStartTime);
       otherSetting.suitShopsSelect = "1";//是否选择全部门店--1：全部，2：部分
       otherSetting.budgetValueSelect = "1"; //发券数量是否受限 1：不限制，2：限制个数
       //新会员招募、开卡关怀的单日、累计领取上限都为每人一次而且不可修改
        if(ACTIVITY_TYPE.NEW_MEMBER.val ==  otherSetting.activityType || 
          ACTIVITY_TYPE.OPEN_CARD_CARE.val ==  otherSetting.activityType){
            otherSetting.userWinCountSelect = 2;//累计领取上限
            otherSetting.userWinCount = 1;

            otherSetting.userWinFrequencySelect = 2;//单日领取上限
            otherSetting.userWinFrequencyValue = 1;
        }else{
            otherSetting.userWinCountSelect = 1;//累计领取上限
            otherSetting.userWinFrequencySelect = 1;//单日领取上限
        }
       otherSetting.voucherSubTitle = createActivityPublicParam.voucherSubTitle;//品牌名称
       otherSetting.voucherLogo = createActivityPublicParam.voucherLogo;//品牌logo
       otherSetting.voucherLogoUri = createActivityPublicParam.voucherLogoUri;//品牌logo
       otherSetting.moneyVoucherType = (createActivityPublicParam.activityType == ACTIVITY_TYPE.ITEM_MARKET.val)?"2":"1";
       otherSetting.voucherWorthValue = createActivityPublicParam.voucherWorthValue;//券面额
       otherSetting.voucherMinConsume = createActivityPublicParam.voucherMinConsume;//消费满
       otherSetting.promoSendRuleMincost = createActivityPublicParam.promoSendRuleMincost;//订单满
       otherSetting.voucherRelativeTime = createActivityPublicParam.voucherRelativeTime;//时间;
	   otherSetting.voucherValidateType =(createActivityPublicParam.isRelativeTime)?"RELATIVE":"FIXED";
       //otherSetting.voucherEffectType = "IMMEDIATELY";//当日生效
        //消费送券默认为次日生效
        if(createActivityPublicParam.activityType==ACTIVITY_TYPE.SEND_FOR_CONSUME.val||
          createActivityPublicParam.activityType==ACTIVITY_TYPE.LATTER_SEND.val||
          createActivityPublicParam.activityType==ACTIVITY_TYPE.CROWD_SEND_FOR_CONSUME.val){
        	if(otherSetting.voucherValidateType == "FIXED"){
                 otherSetting.voucherEffectType = "IMMEDIATELY";//当日生效
        	}else{
        		 otherSetting.voucherEffectType = "DELAY";//次日生效
        	}         
        }else{
            otherSetting.voucherEffectType = "IMMEDIATELY";//当日生效
        }
        
      

       //otherSetting.voucherDonateFlag = "1";//1：可转增，0：不可转增
       //单品营销和扫码送券为可转增
        if(createActivityPublicParam.activityType==ACTIVITY_TYPE.SCAN_CODE.val||
          createActivityPublicParam.activityType==ACTIVITY_TYPE.ITEM_MARKET.val){
          otherSetting.voucherDonateFlag = "1";//1：可转增，0：不可转增
        }else{
          otherSetting.voucherDonateFlag = "0";//1：可转增，0：不可转增
        }
       otherSetting.moneyVoucherType  ="1";
       otherSetting.voucherType = createActivityPublicParam.voucherType;
       otherSetting.voucherName = buildVourcherName();//券名称
   }
    /**
        初始化其他页面默认参数
    **/
   function generateDefaultOtherSetting (){
        var defaultParam = createActivityPublicParam.defaultParam;
        var otherSetting = createActivityPublicParam.otherSetting;
        otherSetting.activityType = defaultParam.activityType;//活动类型
        otherSetting.crowdGroupId = defaultParam.crowdGroupId;//活动人群
        otherSetting.crowdName = defaultParam.crowdName;//
        otherSetting.configCode = defaultParam.configCode;//
        //otherSetting.activityStartTime = createActivityPublicParam.activityStartTime;//活动开始时间

        otherSetting.activityName = buildActivityName(createActivityPublicParam.activityStartTime);
        createActivityPublicParam.activityName = otherSetting.activityName;
        otherSetting.suitShopsSelect = "1";//是否选择全部门店--1：全部，2：部分
        otherSetting.budgetValueSelect = "1"; //发券数量是否受限 1：不限制，2：限制个数
         //新会员招募、开卡关怀的单日、累计领取上限都为每人一次而且不可修改
        if(ACTIVITY_TYPE.NEW_MEMBER.val ==  otherSetting.activityType 
          || ACTIVITY_TYPE.OPEN_CARD_CARE.val ==  otherSetting.activityType
          || ACTIVITY_TYPE.CUSTOMIZE_CROWD_GROUP.val ==  otherSetting.activityType){
            otherSetting.userWinCountSelect = 2;//累计领取上限
            otherSetting.userWinCount = 1;

            otherSetting.userWinFrequencySelect = 2;//单日领取上限
            otherSetting.userWinFrequencyValue = 1;
        }else{
            otherSetting.userWinCountSelect = 1;//累计领取上限
            otherSetting.userWinFrequencySelect = 1;//单日领取上限
        }

        otherSetting.voucherSubTitle = defaultParam.voucherSubTitle;//品牌名称
        otherSetting.voucherLogo = defaultParam.voucherLogo;//品牌logo
        otherSetting.voucherLogoUri = defaultParam.voucherLogoUri;//品牌logo

        //赋值voucherValidateType,方便下一步比对新旧值
        var voucherList = defaultParam.promoTools;
        $.each(voucherList,function(i,voucher){            
            voucher.voucherValidateType = "RELATIVE";
        });

        otherSetting.promoTools = $.extend(true,[],defaultParam.promoTools);

        otherSetting.voucherType = defaultParam.voucherType;//券类型
        otherSetting.moneyVoucherType = "1";//代金券类型
        otherSetting.voucherWorthValue = defaultParam.voucherWorthValue;//券面额
        otherSetting.promoSendRuleMincost = defaultParam.promoSendRuleMincost;//订单满
        otherSetting.voucherMinConsume = defaultParam.voucherMinConsume;//消费满
        otherSetting.voucherValidateType = "RELATIVE";//时间类型
        otherSetting.voucherRelativeTime = defaultParam.voucherRelativeTime;//时间

        //消费送券默认为次日生效
        if(defaultParam.activityType==ACTIVITY_TYPE.SEND_FOR_CONSUME.val||
          defaultParam.activityType==ACTIVITY_TYPE.LATTER_SEND.val||
          defaultParam.activityType==ACTIVITY_TYPE.CROWD_SEND_FOR_CONSUME.val){
            otherSetting.voucherEffectType = "DELAY";//次日生效
        }else{
            otherSetting.voucherEffectType = "IMMEDIATELY";//当日生效
        }

        //单品营销和扫码送券为可转增
        if(defaultParam.activityType==ACTIVITY_TYPE.SCAN_CODE.val||
          defaultParam.activityType==ACTIVITY_TYPE.ITEM_MARKET.val){
          otherSetting.voucherDonateFlag = "1";//1：可转增，0：不可转增
        }else{
          otherSetting.voucherDonateFlag = "0";//1：可转增，0：不可转增
        }

        
        //otherSetting.voucherName = buildVourcherName();//券名称
        //将默认的其他设置页参数赋值给otherSetting
        // if($.isEmptyObject(createActivityPublicParam.otherSetting)){
        //     createActivityPublicParam.otherSetting = defaultOtherSetting;
        // }
    }

   function buildActivityName(activityStartTime) {
        var today = DateUtil.getDateFormat(new Date());
        var activityType = createActivityPublicParam.activityType;
        return Constants.activity.getActivityName(activityType)+"活动"+today;
    }

    function buildVourcherName() {
        var otherSetting = createActivityPublicParam.otherSetting; 

        var moneyVoucherType = "全场代金券";
        if(otherSetting.moneyVoucherType=="1"){
          moneyVoucherType= "全场代金券";
        }else if(otherSetting.moneyVoucherType=="2"){
          moneyVoucherType= "单品券";
        }else if(otherSetting.moneyVoucherType=="3"){
          moneyVoucherType= "兑换券";
        }else if(otherSetting.moneyVoucherType=="4"){
          moneyVoucherType= "折扣券";
        }
        var voucherName = otherSetting.voucherWorthValue+"元" + otherSetting.voucherSubTitle+moneyVoucherType;
        return voucherName;

    }

   
    
    /**
     * 提交创建活动模版抽象;
     */
    function SubmitActivityData() {  
       this.submitData = {};
       if(this.checkParams()==true){
    	   this.saveData();
    	   this.buildSubmitData();
       }     
    }

    SubmitActivityData.prototype.saveData= function () {  	
    };
    SubmitActivityData.prototype.buildSubmitData = function () {  
    };
    SubmitActivityData.prototype.checkParams = function () {  
    	return true;
    };
    
    SubmitActivityData.prototype.send = function () {
    	if(this.checkParams() == true){

        console.info(JSON.stringify(this.submitData));
    		common.loading("提交中"); 
            AppUtil.call(AppUtil.APIS.SEND_HTTP_REQUEST,
                    { 
            	    "data":JSON.stringify(this.submitData),
            	    "type":"POST",
            	    "url":App.serverUrl +"merchantApp/activity/create.do"
                    },
                    function(result){
                      console.info(JSON.stringify(result));
                       
                    	if(result.success.toString() == "true"){//调用服务端正常
                    		  //等待2秒
                           var bussResult = result.resultObject;
                           if(bussResult.success){//服务端处理成功
                                //清空公共参数缓存信息
                                ActivityPreloadData.clearCreateActivityParam(); 
                               //log4JS.info("提交后图片="+createActivityPublicParam.voucherSloganLocalFilePath);            
                                DialogUtil.dialogSuccess("活动提交成功!");
                                CommonUtil.injectParamObject({reload: true});
                                submitFn = true;//打开全局开关
                                sessionStorage.setItem("resetFilter", "true");
                                $.router.load("activity_manage.html"); 
                                common.closeLoading();

                           }else{ //服务器处理失败
                              submitFn = true; 
                              log4JS.info("活动提交失败"+JSON.stringify(bussResult.msg));
                              DialogUtil.dialogWarn("活动提交失败!"+bussResult.msg);
                              common.closeLoading();
                           }
                                               	         		
                    	}else{//服务端调用失败
                    		 common.closeLoading();
                             submitFn = true; 
                             log4JS.info(JSON.stringify(result));
                             DialogUtil.dialogWarn("系统繁忙,请稍后重试!");
                    	}   
                    	
                });
    	
     	}else{
    		submitFn = true;//打开全局开关
    	}
    	  	
    };
    
    
 function closePageWindow(pageId){
	 var $df = $("#"+pageId+" .dailog-form");
 	 $df.removeClass("layer-visible");
 }
 
 function showPageWindow(pageId,divId){
	 closePageWindow(pageId);
	 var $df = $("#"+pageId+" #"+divId);
	 $df.addClass("layer-visible");
 }
 
    
 /**
  * 创建活动预加载数据工具类;
  */   
 var ActivityPreloadData = {
		 executeFuncMaxTime : 5000,
		 
		 executeFuncTimes : 0,
		
		 /**
		  *   {
					"func0" : function() {
						//自己要实现的逻辑方法;
					},
					"func1" : function(){
					},
					.....
					"intervalTime" : 3000,
					"callBackEvent" : function() {
						//同步加载数据结束后，执行的逻辑;
					}
				}
		  * @param params
		  * 支持多个func,用数字结尾表示执行顺序编号;
		  */
		 loadDataTimer :function (params){
			 var tempTime = 0;
			 if(params!=undefined && params!=null){
				 common.loading("页面加载中...");
				 this.initFuncTimes(params);				 
				 for(var key in params){
					 if(key.indexOf("func")!=-1){
						 params[key]();
					 }
				 }
				var intervalTime = 100;
				if(params.intervalTime && params.intervalTime != undefined && params.intervalTime != "" && params.intervalTime!=0){
					intervalTime = params.intervalTime;
				}
				var timer =  setInterval(function(){
					if(tempTime >= ActivityPreloadData.executeFuncMaxTime){
						clearInterval(timer);
						tempTime = 0;
						common.closeLoading();
						ActivityPreloadData.executeFuncTimes=0;
						DialogUtil.dialogWarn("加载数据失败!请检查您的网络.");
						return;
					}			
					if(ActivityPreloadData.executeFuncTimes==0){
						clearInterval(timer);
						params.callBackEvent();			
						common.closeLoading();
						tempTime = 0;
					}else{
						tempTime = tempTime + intervalTime;
					}
				},intervalTime);
			 }		 
		 },
		 
		 initFuncTimes : function(params){
		     var funcNum = 0;
			 for(var key in params){
				 if(key.indexOf("func")!=-1){
					  funcNum++;
				 }
			 }
			 this.executeFuncTimes = funcNum;
		 },
		 //获取创建活动默认单价,代金券默认名称，默认logo图片;
		 createPrerequisite:function(){
			     
		        var serverUrl = App.serverUrl +"merchantApp/activity/createPrerequisite.do?";
		       
		        var sucFunc = function (result) {
		            if (String(result.success) == 'true') {
		                var data = result.resultObject;
		                if(data){
 
		                    createActivityPublicParam.prerequisiteData = data;
		                    if(createActivityPublicParam.prerequisiteData.customerPrice == 0){//如果为0元,设置一个默认;
		                    	createActivityPublicParam.prerequisiteData.customerPrice = 1.00;
		                    }
                            var defaultParam = createActivityPublicParam.defaultParam;
                            defaultParam.voucherLogo = data.brandLogoId;
                            defaultParam.voucherLogoUri = data.brandLogoUrl;
                            var brandName = data.brandName;
                            if(CommonUtil.isEmpty(brandName) && brandName.length>=10){
                            	brandName = brandName.subString(0,10);
                            }
                            defaultParam.voucherSubTitle = brandName;
                            ActivityPreloadData.subtractFuncTimes();   
		                	
		                }

		            } else {
		                DialogUtil.dialogWarn(result.msg);
		                ActivityPreloadData.subtractFuncTimes();   
		            }
		        };

		        var failFunc = function () {
		            log4JS.info("createPrerequisite failed. http status not 200");
		            DialogUtil.dialogWarn();
		            ActivityPreloadData.subtractFuncTimes();   
		        };
		        CommonUtil.sendJsonpRequest({"url":serverUrl,"success":sucFunc,"error":failFunc,"useDefaultLoading":false});
		        
		    },
		    
		 //检查商家是否签约口碑客;    
         checkSupplierIsSignedKouBeiKe : function(){
        	  var serverUrl = App.serverUrl +"merchantApp/activity/checkKoubeiCommissionRole.do?";
		       
		        var sucFunc = function (result) {
		            if (String(result.success) == 'true') {
		                var data = result.resultObject;
		                if(data){
		                    createActivityPublicParam.signedKbk = data.isSignedKbk;
		                    ActivityPreloadData.subtractFuncTimes();   
		                }

		            } else {
		                DialogUtil.dialogWarn(result.msg);
		                ActivityPreloadData.subtractFuncTimes();   
		            }
		        };

		        var failFunc = function () {
		            log4JS.info("checkSupplierIsSignedKbk failed. http status not 200");
		            DialogUtil.dialogWarn();
		            ActivityPreloadData.subtractFuncTimes();   
		        };
		        CommonUtil.sendJsonpRequest({"url":serverUrl,"success":sucFunc,"error":failFunc,"useDefaultLoading":false}); 	 
        	 
         },

         getKouBeiKeConfigInfo : function(){
       	  var serverUrl = App.serverUrl +"merchantApp/activity/queryKoubeiCommissionSetting.do?";
		       
		        var sucFunc = function (result) {
		            if (String(result.success) == 'true') {
		                var data = result.resultObject;
		                if(data){
		                    createActivityPublicParam.kbkConfigInfo = data;
		                    ActivityPreloadData.subtractFuncTimes();                   	
		                }

		            } else {
		                DialogUtil.dialogWarn(result.msg);
		                ActivityPreloadData.subtractFuncTimes();   
		            }
		        };

		        var failFunc = function () {
		            log4JS.info("getKouBeiKeConfigInfo failed. http status not 200");
		            DialogUtil.dialogWarn();
		            ActivityPreloadData.subtractFuncTimes();   
		        };
		        CommonUtil.sendJsonpRequest({"url":serverUrl,"success":sucFunc,"error":failFunc,"useDefaultLoading":false});
       	 
       	 
        },
        
        queryAPayQrCodeCount : function(callBackFunc){	
        	 var serverUrl = App.serverUrl +"merchantApp/activity/queryAPayQrCodeCount.do?";
        	 var sucFunc = function (result) {
		            if (String(result.success) == 'true') {
		                var data = result.resultObject;
		                if(data && data.count >= 3){
		                	 common.confirm({
	  								btnLeft : "知道了",
	  								title : "",
	  								content : "已有3个活动投放至【收银二维码】渠道",
	  								callbackLeft : function() {
	  									submitFn = true;
	  								} 
	  					     });
		                	
		                }else{
		                	callBackFunc();
		                }

		            } else {
		                DialogUtil.dialogWarn(result.msg);
		                               
		            }
		        };

		        var failFunc = function () {
		            log4JS.info("queryAPayQrCodeCount failed. http status not 200");
		            DialogUtil.dialogWarn();
		             
		       };
		       CommonUtil.sendJsonpRequest({"url":serverUrl,"success":sucFunc,"error":failFunc,"useDefaultLoading":false});
 
	     },
		    

		 clearCreateActivityParam : function(){
			 CommonUtil.removeParamObject();//清除sessionStorge;
             createActivityPublicParam = $.extend(true,{},defaultPublicParam);
			 createActivityPublicParam = {
		            "activityType":"",//活动类型 see getActivityName()
		            "crowdGroupId":"",
		            "activityStartTime":"",//活动开始时间
		            "activityEndTime":"",//活动开始时间
		            "voucherStartTime":"",
		            "voucherEndTime":"",
		            "autoDelayFlag":"Y",//自动续期
		            "activityName":"",//活动名称;
		            "voucherLogo":"",//默认券logoId;
		            "voucherLogoUri":"",//默认券logo图片;
		            "voucherSubTitle":"",//默认券名称;
		            "voucherWorthValue":"",//券面额;
		            "voucherMinConsume":"",//券消费门槛;
		            "voucherRelativeTime":"",//默认30天;
		            "isRelativeTime":true,//是否相对时间默认相对;
		            "promoSendRuleMincost":"",
		            "brandName":"",
		            "isOpenKbk":false,//是否开启口碑客,默认关闭;
		            "commissionSettingCheck":"0",//是否分佣金
		            "percentageClauseRate":"",//佣金比例;
		            "percentageClauseMax":"",//限制最大金额;
		            "quotaClauseQuotaAmount":"",//单品固定分佣金额;
		            "voucherSlogan":"",//专项优惠文案;
		            "voucherSloganUrlId":"",//专项优惠图片Id;
		            "voucherSloganUri":"",//专项优惠图片URL;
		            "voucherSloganNewUri":"",//专项优惠图片URL;
		            "voucherSloganNewId":"",//专项优惠图片URL;
		            "voucherSloganLocalFilePath":"",//专项优惠图片本地文件最新的路径;
		            "voucherSloganLocalOldFilePath":"",//专项优惠图片本地文件上一次选择的图片路径;"
		            "signedKbk":false,//是否签约口碑客默认没有签约;
		            "voucherType":ACTIVITY_TICKET_TYPE.ALL_TICKET,
		            //"configCode":"1",//活动配置code
		            "goodsInfo":{},//商品信息;
		            "prerequisiteData":{},//活动预加载数据;
		            "kbkConfigInfo":{},//口碑客默认推荐配置;
		            "otherSetting":{},//其他设置页面设置的;      
		            "defaultParam":{},//首页默认参数
		            "voucherData":[],//设置优惠券信息数据(阶梯有可能为多个);
		            //"defaultEffectData":{},//预期效果默认参数
		            //"defaultOtherSetting":{},//其他设置页默认参数
		            "channelType":[],//渠道类型 店铺: SHOP_DETAIL 支付成功页: PAYMENT_RESULT 短链接: SHORT_LINK 二维码: QR_CODE
		            "affiliation":"",//二维码类型;
		            "channelData":{},
		          "selectDateParams" : {
		              "pageId" : "",//当前页面pageId;
		              "beginDateInputId" : "",//开始日期input的Id;
		              "endDateInputId" : "",//结束日期的input的Id;
		              "selectBeginDateFunc" : "",//开始日期联动执行的选择callback事件
		              "selectEndDateFunc" : "" //结束日期联动执行的选择callback事件
		          }
			 }
	    },
	    
	    initActivityCheckedChannel : function(pageId){
	    	createActivityPublicParam.channelType = [];
	    	var _$channels = $("#" + pageId + " #channels").find("li");
			if(_$channels!=undefined && _$channels!=null && _$channels.length>0){
				 _$channels.each(function(){ 
					   if($(this).attr("class").indexOf("hide")==-1 && $(this).attr("class").indexOf("checked")!=-1){
						   createActivityPublicParam.channelType.push($(this).attr("channel_val"));
					   }			 
				 });
			}
	    	
	    },
	    
	    loadUserServiceInfo : function(){
	    	 var future = CommonUtil.getUserServiceInfo();
	         var self = this;
	         var retryTempTime = 0;
	         var maxRetryTime = 2000;
	         var intervalObj = window.setInterval(function(){
	        	         if(retryTempTime >= maxRetryTime){
	        	        	 window.clearInterval(intervalObj);
	        	        	 ActivityPreloadData.subtractFuncTimes(); 
	        	        	 retryTempTime = 0;
	        	         }
                         if(future.finish){
                             intervalObj && window.clearInterval(intervalObj);
                             if(future.success && future.data!=""){                                        	 
                                var serviceInfo = future.data;
                                createActivityPublicParam.userServiceVersion = serviceInfo.proServiceType;       
                             } 
                             ActivityPreloadData.subtractFuncTimes(); 
                             retryTempTime = 0;                 
                         }else{
                        	 retryTempTime = retryTempTime+100;
                         }
                     }, 100);
	    	
	    },
	    subtractFuncTimes :function(){
	    	if(ActivityPreloadData.executeFuncTimes>0){
	            	ActivityPreloadData.executeFuncTimes--;
      	    }     	
	    }
	    
	    
	 
	 
 }; 
